//
//  MessageViewController.m
//  WangLottery
//
//  Created by 黄修勇 on 12-5-4.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "MessageViewController.h"
#import <QuartzCore/QuartzCore.h>

@interface MessageViewController ()

@end

@implementation MessageViewController
@synthesize msgTableView=_msgTableView;

-(void)dealloc{

    [_msgTableView release];
    [titleArray release];
    [imgNameArray release];
    [super dealloc];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self.view setBackgroundColor:[UIColor colorWithRed:0.9 green:0.9 blue:0.96 alpha:1]];
    titleArray=[[NSArray alloc]initWithObjects:@"官方通知", nil];
    imgNameArray=[[NSArray alloc]initWithObjects:@"tongzhi.png", nil];
    _msgTableView.backgroundColor=[UIColor clearColor];
    _msgTableView.scrollEnabled = NO;
    //_msgTableView.layer.backgroundColor=[UIColor clearColor];
    // Do any additional setup after loading the view from its nib.
    
    //一个标签和4个无效的按钮
    UILabel *companier = [[UILabel alloc] initWithFrame:CGRectMake(20, 70, 70, 30)];
    companier.text = @"合作伙伴";
    companier.backgroundColor = [UIColor clearColor];
    [companier setFont:[UIFont systemFontOfSize:15]];
    [self.view addSubview:companier];
    [companier release];
    
    UIButton *sina = [UIButton buttonWithType:UIButtonTypeCustom];
    UIButton *tencent = [UIButton buttonWithType:UIButtonTypeCustom];
    UIButton *netease = [UIButton buttonWithType:UIButtonTypeCustom];
    UIButton *sohu = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [sina setBackgroundImage:[UIImage imageNamed:@"Sina.png"] forState:UIControlStateNormal];
    [tencent setBackgroundImage:[UIImage imageNamed:@"Tencent.png"] forState:UIControlStateNormal];
    [netease setBackgroundImage:[UIImage imageNamed:@"netEase.png"] forState:UIControlStateNormal];
    [sohu setBackgroundImage:[UIImage imageNamed:@"sohu.png"] forState:UIControlStateNormal];
    
    [sina setFrame:CGRectMake(100, 65, 40, 40)];
    [tencent setFrame:CGRectMake(150, 65, 40, 40)];
    [netease setFrame:CGRectMake(200, 65, 40, 40)];
    [sohu setFrame:CGRectMake(250, 65, 40, 40)];
    
    [self.view addSubview:sina];
    [self.view addSubview:tencent];
    [self.view addSubview:netease];
    [self.view addSubview:sohu];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [titleArray count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *cellString=@"cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellString];
    if (!cell) {
        cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellString] autorelease];
        cell.backgroundColor=[UIColor clearColor];
    }
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.text=[titleArray objectAtIndex:indexPath.row];
    cell.imageView.image=[UIImage imageNamed:[imgNameArray objectAtIndex:indexPath.row]];
    cell.backgroundColor = [UIColor clearColor];
    
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [[_msgTableView cellForRowAtIndexPath:indexPath] setSelected:NO];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
